package studay.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * @program: 设计模式
 * @description:
 * @author: Tom
 * @create: 2022-01-07 17:47
 **/
public class WebSiteFactory {

    /**
     * map里面的key是个分类
     */
    private Map<String,ConcreateWebSite> map = new HashMap<>();

    public CloudWebSite getWebSiteByKey(String category){
        if(map.containsKey(category)){
            return map.get(category);
        }else{
            ConcreateWebSite site = new ConcreateWebSite(category);
            map.put(category,site);
            return site;
        }
    }

    /**
     * 获取分类个数
     * @return
     */
    public int getWebsiteCategorySize(){
        return map.size();
    }
}
